-
Notifications
You must be signed in to change notification settings - Fork 819
samples/guestbook: add sample application #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
samples/guestbook/main.go
Outdated
@@ -261,7 +261,9 @@ func (app *app) serveBlob(w http.ResponseWriter, r *http.Request) { | |||
w.Header().Set("Content-Type", "application/octet-stream") | |||
} | |||
w.Header().Set("Content-Length", strconv.FormatInt(blobRead.Size(), 10)) | |||
io.Copy(w, blobRead) | |||
if _, err = io.Copy(w, blobRead); err != nil { | |||
log.Println("Copying blob:", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Fatal perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because this would mean that a client could kill the whole server.
samples/guestbook/README.md
Outdated
$ gsutil iam ch \ | ||
serviceAccount:${GCP_IAM_ACCOUNT}:objectViewer \ | ||
gs://$GCS_BUCKET_NAME | ||
# On your own: download a GCP icon to gcp.png. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a good idea to put this further up. A lot of users would probably want to copy paste all of this in one go; it'd be a very nice experience if the instructions are set up to allow them to do that.
samples/guestbook/README.md
Outdated
select. | ||
|
||
```shell | ||
$ PROJECT_ID=... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of users would probably want to copy paste all of this in one go; it'd be nice if we didn't have dollar signs. While they convey "this is a shell prompt", it seems to me a small gain to lose copy paste-ability.
Not sure if some syntax guide talks about this, though, or if we have a convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes I've seen people confused that they need to copy-paste into a shell unless they see prompts. I've removed for now.
samples/guestbook/README.md
Outdated
select. | ||
|
||
```shell | ||
$ AWS_ACCT_ID="$( aws sts get-caller-identity --query=Account --output=text )" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this assume some logged in state? If so, can we be transparent about that intention further up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/README.md
Outdated
$ gcloud iam service-accounts delete $GCP_IAM_ACCOUNT | ||
``` | ||
|
||
## Running on Amazon Web Services (AWS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comment: these two blocks (running on aws, running on gcp) are very dense. Could we add some comments about what some of the blocks are doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obsoleted by Terraform rewrite.
samples/guestbook/README.md
Outdated
admin@ec2$ AWS_REGION=us-west-1 ./guestbook -env=aws | ||
``` | ||
|
||
### Introspection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide a short sentence describing what this section is about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to that. A little hand-holding for these samples is invaluable. Nothing too wordy, but a few sentences would go a long way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really needed anymore, since the values are now surfaced more succinctly in terraform output
.
samples/guestbook/inject_aws.go
Outdated
) | ||
|
||
// Configure these to your AWS project. | ||
const ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be env vars? I think most people in cloud environments (e.g. docker images) are used to getting config into source code via env vars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely. Don't want to come across as sanctioning hard-coding config and secrets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using command-line flags now.
samples/guestbook/main.go
Outdated
} | ||
} | ||
|
||
// index serves the server's landing page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super, super nit: could these comments be terminated equally apart (and, bring line 2 up to line 1)? Line 1 is terminated far sooner than line 2.
This is an ultra nit, feel free to ignore if it doesn't bother you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how this happened. 😄 Thanks!
return | ||
} | ||
defer q.Close() | ||
for q.Next() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid dup of error-handling code, consider:
var err error
for q.Next() {
...
err = q.Scan(...)
if err != nil {break}
...
}
if err == nil {
err = q.Err()
}
if err != nil {
log...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read your suggestion slightly incorrectly and filed golang/go#25787. There's a bit too much mutable state for me in your suggestion, so I'm going to keep it as is.
@@ -0,0 +1,266 @@ | |||
# Guestbook Sample | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a few sentences summarizing what this sample does, e.g., "Guestbook is a sample application which records visitors' names. It also demonstrates a common (standard, conventional?) use of go-wire and go-cloud."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
``` | ||
|
||
## Running Locally | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again a quick summary here would be nice. "You will need to run a MySQL database using Docker and then migrate that database. Then, you can start the app locally" or something similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/README.md
Outdated
# Guestbook Sample | ||
|
||
## Building | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. "You will need to install vgo with ... The vgo vendor step pulls down all required dependencies specified in go.mod"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/README.md
Outdated
select. | ||
|
||
```shell | ||
$ PROJECT_ID=... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a huge amount of commands, which makes for an error prone UX. Could this be moved into a script with the user just setting a handful of environment variables before executing the script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed over IM. I didn't know that Terraform was exactly the thing I needed, so I've rewritten this with Terraform. Thanks!
samples/guestbook/README.md
Outdated
You will also need to modify `inject_aws.go` with the configuration values you | ||
select. | ||
|
||
```shell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. This should be moved into a script. The average user will be scared away otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a lazy software engineer, I would probably give up on this tutorial on seeing these commands honestly. This step should be made as easy as possible, e.g., export these environment variables and run the script.
Also, although it might be obvious to someone who's been deep in the guts of GCP and AWS CLIs, the average user won't understand a lot of this stuff. So, once you move the commands into a script, add copious annotations explaining each step for the curious reader who wants to understand what you've asked them to do to their IaaS account.
|
||
//+build wireinject | ||
|
||
package main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A package doc would be good here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in main.go.
samples/guestbook/inject_aws.go
Outdated
paramstoreVar = "/guestbook/motd" | ||
) | ||
|
||
func setupAWS(ctx context.Context) (*app, func(), error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some brief documentation would be good here. Your users will learn by repetition, so don't be afraid of being explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly documentation and UX concerns here.
samples/guestbook/inject_aws.go
Outdated
)) | ||
} | ||
|
||
func awsBucket(ctx context.Context, cp awsclient.ConfigProvider) (*blob.Bucket, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation here. Again, it's obvious to the long-time user, but when promoting a DI framework, lots of clear explanations will go a long way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/inject_gcp.go
Outdated
"github.com/google/go-cloud/wire" | ||
) | ||
|
||
// Configure these to your GCP project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above about not hard coding these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/inject_gcp.go
Outdated
runtimeConfigVar = "motd" | ||
) | ||
|
||
func setupGCP(ctx context.Context) (*app, func(), error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. Documentation here and for all the functions below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/inject_local.go
Outdated
motdFile = "motd.txt" | ||
) | ||
|
||
func setupLocal(ctx context.Context) (*app, func(), error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some documentation here as well. "setupLocal creates bindings which allow for local development independent of any IaaS resources" or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/main.go
Outdated
flag.Parse() | ||
|
||
ctx := context.Background() | ||
var app *app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stutter in the variable name. The type already tells us it's an app. Since app is used only in this function, a
comes across as idiomatic to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, change the type name to application
and use app
as the variable name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to application
.
samples/guestbook/main.go
Outdated
|
||
// app is the main server struct for Guestbook. | ||
type app struct { | ||
backends |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A pluralized noun for a single type seems strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below, I've removed the backends
type.
samples/guestbook/main.go
Outdated
motd string // message of the day | ||
} | ||
|
||
// backends is a set of platform-independent services that the Guestbook uses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the word "set" but see nothing in the fields which indicates there is more than one Server
. Do you mean that srv
, db
, and bucket
each represent an IaaS-specific resource? Why have the separate type instead of just putting them directly on app
? A little more explanation in the documentation on the "why" would be helpful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed backends
struct because it is indeed confusing. It was mostly an attempt to make it "one line to add new dependencies". Upon reflection, it is definitely contorting the application structure to show off a neat trick with Wire, but it does not help with clarity.
Thank you all for the feedback! I'm going to move the platform setup out of the README and into a Terraform configuration (kudos to @enocom for pointing me to it!), which should alleviate a lot of the "big wall o' CLI" concerns, as well as making the setup much more maintainable. I'll ping back here when I've done this and addressed the other comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL. I believe I've made most of the requested changes, although I haven't had a chance to re-test everything with the new setup.
samples/guestbook/README.md
Outdated
select. | ||
|
||
```shell | ||
$ PROJECT_ID=... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed over IM. I didn't know that Terraform was exactly the thing I needed, so I've rewritten this with Terraform. Thanks!
samples/guestbook/README.md
Outdated
$ gcloud iam service-accounts delete $GCP_IAM_ACCOUNT | ||
``` | ||
|
||
## Running on Amazon Web Services (AWS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obsoleted by Terraform rewrite.
@@ -0,0 +1,266 @@ | |||
# Guestbook Sample | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/README.md
Outdated
# Guestbook Sample | ||
|
||
## Building | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
``` | ||
|
||
## Running Locally | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/main.go
Outdated
flag.Parse() | ||
|
||
ctx := context.Background() | ||
var app *app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to application
.
samples/guestbook/main.go
Outdated
|
||
// app is the main server struct for Guestbook. | ||
type app struct { | ||
backends |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below, I've removed the backends
type.
samples/guestbook/main.go
Outdated
motd string // message of the day | ||
} | ||
|
||
// backends is a set of platform-independent services that the Guestbook uses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed backends
struct because it is indeed confusing. It was mostly an attempt to make it "one line to add new dependencies". Upon reflection, it is definitely contorting the application structure to show off a neat trick with Wire, but it does not help with clarity.
samples/guestbook/main.go
Outdated
} | ||
} | ||
|
||
// index serves the server's landing page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how this happened. 😄 Thanks!
return | ||
} | ||
defer q.Close() | ||
for q.Next() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read your suggestion slightly incorrectly and filed golang/go#25787. There's a bit too much mutable state for me in your suggestion, so I'm going to keep it as is.
Very nice. Looks much cleaner and more user-friendly. I'll do a test run through the tutorial to verify all the instructions work and so on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a syntax error in the script starting the local DB and as permissions stand in a new project, the terraform apply step fails.
samples/guestbook/README.md
Outdated
Guestbook is a sample application that records visitors' messages, displays a | ||
cloud banner, and an administrative message. The main business logic is | ||
written in a cloud-agnostic manner using MySQL, the generic blob API, and the | ||
generic runtimevar API. Each of the platform-specific code is set up by Wire. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"All platform-specific code" reads better to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/start-localdb.sh
Outdated
@@ -0,0 +1,52 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The executable bits should be flipped on this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the current state:
-rw-r--r-- 1 enocom eng 1568 Jun 8 10:16 start-localdb.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/start-localdb.sh
Outdated
--interactive \ | ||
--link "${container_name}:mysql" \ | ||
"$image" \ | ||
sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -ppassword guestbook' || { \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a syntax error on this line and the script currently does not run.
Make sure to run shellcheck against all bash scripts to make sure their in tip-top shape.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shellcheck is more magical than I expected and I am pleased. Thank you again for showing me the coolest tools. 👍
samples/guestbook/README.md
Outdated
./start-localdb.sh | ||
./guestbook -env=local | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After it's all turned on, what do I do? What address do I visit in my browser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/README.md
Outdated
can run the server. | ||
|
||
```shell | ||
./start-localdb.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid the pain of users forgetting to stop their container, you could make this a foregrounded process and tell the user to open a new session, tab, window, etc.
samples/guestbook/README.md
Outdated
gcloud auth application-default login | ||
cd gcp | ||
terraform init | ||
terraform apply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terraform prompts me for a project, a region, and a zone. Might be helpful to add a one-liner about what a user should enter to ease any friction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/README.md
Outdated
gcloud auth application-default login | ||
cd gcp | ||
terraform init | ||
terraform apply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what I get when I follow this verbatim using my personal account on GCP:
Error: Error applying plan:
6 error(s) occurred:
* google_project_service.runtimeconfig: 1 error(s) occurred:
* google_project_service.runtimeconfig: Error enabling service: failed to issue request: googleapi: Error 403: The caller does not have permission, forbidden
* google_project_service.storage: 1 error(s) occurred:
* google_project_service.storage: Error enabling service: failed to issue request: googleapi: Error 403: The caller does not have permission, forbidden
* google_service_account.db_access: 1 error(s) occurred:
* google_service_account.db_access: Error creating service account: googleapi: Error 403: Permission iam.serviceAccounts.create is required to perform this operation on project projects/go-cloud-test., forbidden
* google_service_account.server: 1 error(s) occurred:
* google_service_account.server: Error creating service account: googleapi: Error 403: Permission iam.serviceAccounts.create is required to perform this operation on project projects/go-cloud-test., forbidden
* google_project_service.sql: 1 error(s) occurred:
* google_project_service.sql: Error enabling service: failed to issue request: googleapi: Error 403: The caller does not have permission, forbidden
* google_project_service.container: 1 error(s) occurred:
* google_project_service.container: Error enabling service: failed to issue request: googleapi: Error 403: The caller does not have permission, forbidden
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is hashicorp/terraform-provider-google#1579. I was getting it too and was about to start bothering folks.
The use of terraform is a big win, though. It's going to be a big improvement over raw commands. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
samples/guestbook/README.md
Outdated
gcloud auth application-default login | ||
cd gcp | ||
terraform init | ||
terraform apply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is hashicorp/terraform-provider-google#1579. I was getting it too and was about to start bothering folks.
samples/guestbook/README.md
Outdated
Guestbook is a sample application that records visitors' messages, displays a | ||
cloud banner, and an administrative message. The main business logic is | ||
written in a cloud-agnostic manner using MySQL, the generic blob API, and the | ||
generic runtimevar API. Each of the platform-specific code is set up by Wire. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/README.md
Outdated
./start-localdb.sh | ||
./guestbook -env=local | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/README.md
Outdated
gcloud auth application-default login | ||
cd gcp | ||
terraform init | ||
terraform apply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/start-localdb.sh
Outdated
@@ -0,0 +1,52 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
samples/guestbook/start-localdb.sh
Outdated
--interactive \ | ||
--link "${container_name}:mysql" \ | ||
"$image" \ | ||
sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -ppassword guestbook' || { \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shellcheck is more magical than I expected and I am pleased. Thank you again for showing me the coolest tools. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple more issues with the service account permissions on GCP. I didn't test AWS. Otherwise, once the permissions are fixed, I think this is ready to merge.
samples/guestbook/README.md
Outdated
In another terminal, you can run: | ||
|
||
```shell | ||
./guestbook -env=local |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a fresh clone after following all instructions up to this point, I get this:
$ ./guestbook -env=local
2018/06/13 15:45:16 open file bucket: stat : no such file or directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
|
||
Your server should be running on http://localhost:8080/. | ||
|
||
You can stop the MySQL database server with Ctrl-\. MySQL ignores Ctrl-C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very nice touch. I would have mashed ctrl-c endlessly otherwise.
|
||
# Terraform will prompt you for your GCP project ID, desired region, | ||
# and desired zone. | ||
terraform apply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Granted, I know how to fix this myself by enabling the API (i.e., gcloud services enable container.googleapis.com
) and adjusting IAM permissions, but it would be nice if README told me to do this or if the terraform config was updated to ensure permissions worked out of the box.
After running terraform apply
on a vanilla setup against a fresh account, I get this:
3 error(s) occurred:
* google_project_service.storage: 1 error(s) occurred:
* google_project_service.storage: Error enabling service: failed to issue request: googleapi: Error 403: The caller does not have permission, forbidden
* google_project_service.sql: 1 error(s) occurred:
* google_project_service.sql: Error enabling service: failed to issue request: googleapi: Error 403: The caller does not have permission, forbidden
* google_project_service.container: 1 error(s) occurred:
* google_project_service.container: Error enabling service: Error waiting for apis ["container.googleapis.com"] to be enabled for enocom-dev: googleapi: Error 403: The caller does not have permission, forbidden
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ironically, I believe these messages come up because the services are already enabled. :\ Tracking bug is hashicorp/terraform-provider-google#1579
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for your patience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very nice!! Nice one Ross 👍
@cflewis, any idea why I'm getting this weird (merge-blocking) failure? https://travis-ci.com/google/go-cloud/builds/76231027#L632 |
It's almost certainly #58 . I'll send a PR to just skip that test. |
Hmm, no, it's not #58. I think Travis flaked. There's no reason it shouldn't have any space on the device, the tests write tiny files. I kicked off the build again and we'll see what happens. |
OK, the build is happy now. Except that |
The vgo fix (https://golang.org/cl/118757) unmasks a different failure that @rsc is actively debugging (the |
vgo fix is coming in golang.org/cl/118956. |
This is a cleaned up sample code version of my Guestbook demo from a few weeks ago. Please review and let me know what you think.
This is too large for a "Hello, World!" snippet, since it is targeted at exercising all parts of the SDK (all clouds and all generic interfaces in one binary). What you can glean from this demo is a sense for what a mid-sized "go-cloud" application configured with Wire would look like.